<?php
/**
 * Created by PhpStorm.
 * User: LYQ
 * Date: 2019/6/22
 * Time: 17:14
 */

namespace app\admin\controller;

use app\admin\model\User;
use think\Validate;

class Register
{
    public function saveUser(){
        $request = request();
        dump($request->param());
        $name = $request->param('name');
        $email = $request->param('email');
        $psw1 = $request->param('password1');
        $psw2 = $request->param('password2');

      $validate = new Validate([
            'name'  => 'require|max:20',
            'email' => 'email',
            'psw1' => 'require|max:10',
            'psw2' => 'require|max:10'
        ]);
      $data = [
            'name'  => $name,
            'email' => $email,
            'psw1' => $psw1,
            'psw2' => $psw2
        ];
       if (!$validate->check($data)) {

            dump($validate->getError());
        }
        /*if($psw1 != $psw2){
            return;
        }*/
        $user = new User();
       $res = $user->addUser($name,$email,$psw1);
       if($res == true){
           return view('admin/login.php');
       }

    }
}